Pay attention! Admonitions in Hugo!
An admonition is, according to the dictionary, a firm warning or reprimand. But in documentation and the programming world, they are less threatening - they are just some boxes with warnings, info or an aside.

Admonitions as they appear in the popular Material for MkDocs.
I have created my own admonitions for use on this site. It is very minimal, and my opinion, very cool. See the very cool one below:

In Hugo, articles (like this one) are typically written in the Markdown language. This means you cannot just enter arbitrary HTML and CSS to get something that looks like the above. However, one of the prominent Hugo features is the shortcode, a keyword in the markdown file, that when invoked, generates some arbitrary HTML. The shortcode for my admonition is seen below:
|
|
Anyone familiar with HTML will see this and think “ew, he butchered it”. The litter of {{ }}
elements you see, are Go templates, that lets you, amongst other things, take arguments to the template. For example, the admonition above is produced by the following code:
{{`< admonition title="Hej" color="yellow" icon="smiley.png" >}}
Hej med dig!
{{`< /admonition >}}

On top of this, I have made a SASS (a pre-processor for CSS) file to style the admonitions. This is what gives it color, background color, mono font and scales the icon. I don’t want to gatekeep how I styled the elements, but it takes up some space, so I just suggest you inspect the stylesheet of this page.
The shortcode is very flexible, being able to use any title, any color (if defined in the .scss
file) and any icon. See below:



Published 29. May 2025
Last modified 29. May 2025